home *** CD-ROM | disk | FTP | other *** search
/ MacFormat UK 199 / MF_UK_199_1.iso / pc / DiscContents / In the mag / Widgets / Localhostr Widget 1.1 / Widget / localhostr-1.1.0.wdgt / localhostr.js < prev   
Encoding:
JavaScript  |  2008-07-10  |  18.7 KB  |  654 lines

  1. // This file was generated by Dashcode from Apple Inc.
  2. // You may edit this file to customize your Dashboard widget.
  3.  
  4. var cmd1;
  5. var numofitems;
  6. var date;
  7. var itemAnimator;
  8. var scrollArea;
  9. var scrollBar;
  10. var scrollAreaDiv;
  11. var droparea;
  12. var growboxInset;
  13. var updateTimer;
  14.  
  15. //
  16. // Function: load()
  17. // Called by HTML body element's onload event when the widget is ready to start
  18. //
  19. function load()
  20. {
  21.     setupParts();
  22.  
  23.     droparea        = document.getElementById('droparea');
  24.     scrollAreaDiv    = document.getElementById('scrollArea');
  25.     cmd1            = new Object();
  26.     numofitems        = 0;
  27.     itemAnimator    = new AppleAnimator(500, 13);
  28.     
  29.     scrollBar = new AppleVerticalScrollbar(document.getElementById("scrollBar"));
  30.     scrollArea = new AppleScrollArea(document.getElementById("scrollArea"));
  31.     
  32.     scrollBar.setTrackStart('Images/trackTop.png', 9);
  33.     scrollBar.setTrackMiddle('Images/trackMiddle.png');
  34.     scrollBar.setTrackEnd('Images/trackBottom.png', 9);
  35.     scrollBar.setThumbStart('Images/thumbTop.png', 12);
  36.     scrollBar.setThumbMiddle('Images/thumbMiddle.png');
  37.     scrollBar.setThumbEnd('Images/thumbBottom.png', 12);
  38.     scrollArea.singlepressScrollPixels = 3;
  39.     
  40.     scrollArea.addScrollbar(scrollBar);
  41.     
  42.     if (widget.preferenceForKey('lhostrhistory') != null) 
  43.     {
  44.         scrollAreaDiv.innerHTML = widget.preferenceForKey('lhostrhistory');
  45.         scrollArea.refresh();
  46.     }
  47.     
  48.     if (widget.preferenceForKey('lhwidgetheight') != null) 
  49.     {
  50.         setTimeout("adjustWidgetHeight(widget.preferenceForKey('lhwidgetheight'), 338, 1)", 700);
  51.     }
  52.     
  53.     var images = scrollAreaDiv.getElementsByTagName("img");
  54.     for (var f = 0; f<images.length; f++) {
  55.         images[f].onload = function(event) {
  56.             scrollArea.refresh();
  57.         }
  58.     }
  59.     
  60.     if (widget.preferenceForKey('username') != null) {
  61.         document.getElementById("username").value = widget.preferenceForKey('username');
  62.         document.getElementById("password").value = 'pswdissekrit';
  63.         verifyOnLoad(null);
  64.     }
  65.     
  66.     if (widget.preferenceForKey('updatesOnOff') == '1' || widget.preferenceForKey('updatesOnOff') == undefined) {
  67.         checkForUpdates(null);
  68.         document.getElementById('updatesOnOff').checked = true;
  69.     }
  70.     else {
  71.         document.getElementById('updatesOnOff').checked = false;
  72.     }
  73.     
  74.     if (widget.preferenceForKey('autocopy') == '1') {
  75.         document.getElementById('copyOnOff').checked = true;
  76.     }
  77.     else {
  78.         document.getElementById('copyOnOff').checked = false;
  79.     }
  80. }
  81.  
  82. //
  83. // Function: remove()
  84. // Called when the widget has been removed from the Dashboard
  85. //
  86. function remove()
  87. {
  88.     // Stop any timers to prevent CPU usage
  89.     // Remove any preferences as needed
  90.     // widget.setPreferenceForKey(null, createInstancePreferenceKey("your-key"));
  91.     
  92.     widget.setPreferenceForKey(null, createInstancePreferenceKey("username"));
  93.     widget.setPreferenceForKey(null, createInstancePreferenceKey("password"));
  94.     widget.setPreferenceForKey(null, createInstancePreferenceKey("lhwidgetheight"));
  95.     widget.setPreferenceForKey(null, createInstancePreferenceKey("lhostrhistory"));
  96. }
  97.  
  98. //
  99. // Function: hide()
  100. // Called when the widget has been hidden
  101. //
  102. function hide()
  103. {
  104.     // Stop any timers to prevent CPU usage
  105. }
  106.  
  107. //
  108. // Function: show()
  109. // Called when the widget has been shown
  110. //
  111. function show()
  112. {
  113.     // Restart any timers that were stopped on hide
  114. }
  115.  
  116. //
  117. // Function: sync()
  118. // Called when the widget has been synchronized with .Mac
  119. //
  120. function sync()
  121. {
  122.     // Retrieve any preference values that you need to be synchronized here
  123.     // Use this for an instance key's value:
  124.     // instancePreferenceValue = widget.preferenceForKey(null, createInstancePreferenceKey("your-key"));
  125.     //
  126.     // Or this for global key's value:
  127.     // globalPreferenceValue = widget.preferenceForKey(null, "your-key");
  128. }
  129.  
  130. //
  131. // Function: showBack(event)
  132. // Called when the info button is clicked to show the back of the widget
  133. //
  134. // event: onClick event from the info button
  135. //
  136. function showBack(event)
  137. {
  138.     var front = document.getElementById("front");
  139.     var back = document.getElementById("back");
  140.  
  141.     adjustWidgetHeight(338, 0, 0);
  142.     
  143.     setTimeout(function(){
  144.     if (window.widget) {
  145.         widget.prepareForTransition("ToBack");
  146.     }
  147.  
  148.     front.style.display = "none";
  149.     back.style.display = "block";
  150.  
  151.     if (window.widget) {
  152.         setTimeout('widget.performTransition();', 100);
  153.     }
  154.     }, 1);
  155. }
  156.  
  157. //
  158. // Function: showFront(event)
  159. // Called when the done button is clicked from the back of the widget
  160. //
  161. // event: onClick event from the done button
  162. //
  163. function showFront(event)
  164. {
  165.     var front = document.getElementById("front");
  166.     var back = document.getElementById("back");
  167.     
  168.     if (widget.preferenceForKey('lhwidgetheight') != null) {
  169.         adjustWidgetHeight(widget.preferenceForKey('lhwidgetheight'), 0, 0);
  170.         setTimeout('scrollArea.refresh()', 1);
  171.     }
  172.     
  173.     if (window.widget) {
  174.         widget.prepareForTransition("ToFront");
  175.     }
  176.  
  177.     front.style.display="block";
  178.     back.style.display="none";
  179.  
  180.     if (window.widget) {
  181.         setTimeout('widget.performTransition();', 0);
  182.     }
  183. }
  184.  
  185. if (window.widget) {
  186.     widget.onremove = remove;
  187.     widget.onhide = hide;
  188.     widget.onshow = show;
  189.     widget.onsync = sync;
  190. }
  191.  
  192. function dragdrop (event)
  193. {
  194.     var uri = null;
  195.     try {
  196.         uri = event.dataTransfer.getData("text/uri-list");    // attempt to load the new
  197.     } catch (ex)                                            // image
  198.     {
  199.     }
  200.     
  201.     // if the acquisition is successful:
  202.     if (uri && uri.length>0)
  203.     {
  204.         event.stopPropagation();
  205.         event.preventDefault();
  206.         startUpload(uri);
  207.     }
  208.     else
  209.     {
  210.         event.stopPropagation();
  211.         event.preventDefault();
  212.         alert('An error occured');
  213.         droparea.style.opacity = 0;
  214.         document.getElementById('uploading').style.opacity = 0;
  215.         
  216.         setTimeout(function(){dropareaAnimator = new AppleAnimator(1000, 26);
  217.         
  218.         dropareaAnimation = new AppleAnimation(0.0, 1.0, function(animation, current, start, finish)
  219.         {
  220.             droparea.style.opacity = current;
  221.         });
  222.         
  223.         dropareaAnimator.addAnimation(dropareaAnimation);
  224.         dropareaAnimator.start();}, 5000);
  225.         setTimeout("document.getElementById('uploading').style.opacity = 1;", 6000);
  226.     }
  227. }
  228.  
  229. function dragenter (event)
  230. {
  231.     event.stopPropagation();
  232.     event.preventDefault();
  233. }
  234.  
  235. function dragover (event)
  236. {
  237.     event.stopPropagation();
  238.     event.preventDefault();
  239. }
  240.  
  241. function dragleave (event)
  242. {
  243.     event.stopPropagation();
  244.     event.preventDefault();
  245. }
  246.  
  247. function basename(path, suffix) {
  248.     // http://kevin.vanzonneveld.net
  249.     // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  250.     // +   improved by: Ash Searle (http://hexmen.com/blog/)
  251.     // +   improved by: Lincoln Ramsay
  252.     // +   improved by: djmix
  253.     // *     example 1: basename('/www/site/home.htm', '.htm');
  254.     // *     returns 1: 'home'
  255.  
  256.     var b = path.replace(/^.*[\/\\]/g, '');
  257.     if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
  258.         b = b.substr(0, b.length-suffix.length);
  259.     }
  260.     return b;
  261. }
  262.  
  263. function startUpload (localuri)
  264. {
  265.     var cancelimage = document.getElementById('cancel');
  266.     droparea.style.opacity=0;
  267.     cancelimage.style.display = "block";
  268.     if (numofitems == 0)
  269.         cmd1 = new Object();
  270.     
  271.     localuri = localuri.split('\n');
  272.  
  273.     for (key in localuri)
  274.     {
  275.         var newlocaluri = localuri[key].replace(/file:\/\/localhost/, '');
  276.         var filename = basename(newlocaluri.replace(/\%20/g, ' '));
  277.         newlocaluri = newlocaluri.replace(/\%20/g, '\\ ');
  278.         newlocaluri = newlocaluri.replace(/\&/g, '\\&');
  279.         
  280.         if (newlocaluri.substr(-1,1) != '/')
  281.         {
  282.             command = '/usr/bin/curl -F Filedata=@' + newlocaluri + ' -F "username=' + widget.preferenceForKey('username') + '" -F "hashed_password=' + widget.preferenceForKey('password') + '" http://www.localhostr.com/api';
  283.             alert(command);
  284.             cmd1[key] = widget.system(command, finishUpload);
  285.             numofitems = numofitems + 1;
  286.         }
  287.         
  288.         else {
  289.             alert('Is a directory');
  290.             
  291.             droparea.style.opacity = 0;
  292.             document.getElementById('uploading').style.opacity = 0;
  293.             
  294.             if (numofitems == 0 && localuri.length <= 1)
  295.             {
  296.                 cancelimage.style.display = "none";
  297.                 setTimeout(function(){dropareaAnimator = new AppleAnimator(1000, 26);
  298.                 
  299.                 dropareaAnimation = new AppleAnimation(0.0, 1.0, function(animation, current, start, finish)
  300.                 {
  301.                     droparea.style.opacity = current;
  302.                 });
  303.                 
  304.                 dropareaAnimator.addAnimation(dropareaAnimation);
  305.                 dropareaAnimator.start();}, 5000);
  306.             }
  307.             setTimeout("document.getElementById('uploading').style.opacity = 1;", 6000);
  308.         }
  309.     }
  310. }
  311. function cancelFileUpload (event)
  312. {
  313.     var cancelimage = document.getElementById('cancel');
  314.     for (key in cmd1)
  315.     {
  316.         cmd1[key].cancel();
  317.     }
  318.     cmd1 = new Object();
  319.     droparea.style.opacity = 1;
  320.     cancelimage.style.display = "none";
  321.     numofitems = 0;
  322. }
  323.  
  324. function finishUpload (command)
  325. {
  326.     file = command.outputString.split(',');
  327.     filename = basename(file[0]);
  328.     date = new Date();
  329.     var cancelimage = document.getElementById('cancel');
  330.     var uploadTarget = scrollAreaDiv;
  331.     var uploadArea = scrollArea;
  332.     
  333.     file[0] = file[0].replace(/ /g, '+');
  334.     
  335.     icon = 'http://localhostr.com' + file[1];
  336.     
  337.     icon = icon.replace(/ /g, '+');
  338.     
  339.     var newHTML = generateFileHTML(file[0], filename, icon, date);
  340.     
  341.     uploadTarget.innerHTML = newHTML + uploadTarget.innerHTML;
  342.     
  343.     // This code was "inspired" by the SVN Revision widget
  344.     // http://lab.arc90.com/2008/04/svn_notifier.php
  345.     
  346.     var growlcmd = '/usr/bin/osascript growl.scpt "Your file, ' + filename + ', has been uploaded successfully"';
  347.     
  348.     cmd2 = widget.system(growlcmd, function(){null});
  349.     
  350.     if (widget.preferenceForKey('lhwidgetheight') == 192) {
  351.         adjustWidgetHeight(265, 192, 0);
  352.         setTimeout("adjustWidgetHeight(192, 265, 0)", 20000);
  353.     }
  354.     
  355.     widget.setPreferenceForKey(uploadTarget.innerHTML, 'lhostrhistory');
  356.     
  357.     if ((numofitems == 1) && (document.getElementById('copyOnOff').checked == true))
  358.     {
  359.         widget.system("/bin/echo -n '" + file[0] + "' | pbcopy", null);
  360.         alert('copied URL');
  361.     }
  362.     
  363.     numofitems = numofitems - 1;
  364.     
  365.     var images = scrollAreaDiv.getElementsByTagName("img");
  366.     for (var f = 0; f<images.length; f++) {
  367.         images[f].onload = function(event) {
  368.             scrollArea.refresh();
  369.         }
  370.     }
  371.     scrollArea.refresh();
  372.     
  373.     if (numofitems == 0)
  374.     {
  375.         dropareaAnimator = new AppleAnimator(1000, 26);
  376.         
  377.         dropareaAnimation = new AppleAnimation(0.0, 1.0, function(animation, current, start, finish)
  378.         {
  379.             droparea.style.opacity = current;
  380.         });
  381.         
  382.         dropareaAnimator.addAnimation(dropareaAnimation);
  383.         dropareaAnimator.start();
  384.         cancelimage.style.display = 'none';
  385.     }
  386. }
  387.  
  388. function copyURL(url, objreference) 
  389. {
  390.     widget.system("/bin/echo -n '" + url + "' | pbcopy", null);
  391.     objreference.innerText = 'URL COPIED';
  392.     setTimeout(function(){objreference.innerText = '+ COPY URL'}, 5000);
  393. }
  394.  
  395. function generateFileHTML(url, filename, icon, date)
  396. {
  397.     var displayDate = getSimpleDate(date);
  398.     if (filename.length > 25)
  399.     {
  400.         filename = filename.substr(0,25);
  401.         filename += '...';
  402.     }
  403.     var newHTML = '<div id="' + date + '" class="container" valign="middle" style="opacity:1;">';
  404.     newHTML = newHTML + '<div class="thumbDiv" valign="middle"><img src="' + icon + '" class="thumb"></div>';
  405.     newHTML = newHTML + '<div class="fileinfo">'
  406.     newHTML = newHTML + '<h1>' + filename + '</h1>';
  407.     newHTML = newHTML + '<div class="filedate">' + displayDate + '</div>';
  408.     newHTML = newHTML + '<div class="copyurl" onclick="' + "copyURL('" + url + "', this)" + '">+ COPY URL</div>';
  409.     newHTML = newHTML + '</div>';
  410.     newHTML = newHTML + '</div>';
  411.     
  412.     return newHTML;
  413. }
  414.  
  415. function clear()
  416. {
  417.     scrollAreaDiv.innerHTML = '';
  418.     widget.setPreferenceForKey('', 'lhostrhistory');
  419.     scrollArea.refresh();
  420.     showFront();
  421. }
  422.  
  423. function getSimpleDate(date)
  424. {
  425.     var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  426.     var days = new Array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
  427.     
  428.     var month = months[date.getMonth()];
  429.     var dayofmonth = date.getDate();
  430.     var day = days[date.getDay()];
  431.     var year = date.getFullYear();
  432.     if (date.getMinutes() < 10) {
  433.         var minutes = '0' + date.getMinutes();
  434.     }
  435.     else {
  436.         var minutes = date.getMinutes();
  437.     }
  438.     var time = date.getHours() + ':' + date.getMinutes();
  439.     
  440.     var newdate = day + ', ' + month + ' ' + dayofmonth + ', ' + year + ', ' + time;
  441.     
  442.     return newdate;
  443. }
  444.  
  445. function verify(event)
  446. {
  447.     document.getElementById("loginstatus").innerHTML = 'Please wait, verifying...';
  448.     var username = document.getElementById("username");
  449.     var password = document.getElementById("password");
  450.     // Values you provide
  451.     var URL = "http://localhostr.com/api_verify";                        // The feed to fetch
  452.     var onloadHandler = function() { xmlLoaded(xmlRequest, username, password); };    // The function to call when the feed is loaded; currently calls the XMLHttpRequest load snippet
  453.     var hashed = widget.system("/bin/echo -n '" + password.value + "' | /usr/bin/openssl dgst -sha1 ", null).outputString;
  454.     // XMLHttpRequest setup code
  455.     var xmlRequest = new XMLHttpRequest();
  456.     xmlRequest.onload = onloadHandler;
  457.     xmlRequest.open("POST", URL);
  458.     xmlRequest.setRequestHeader("Cache-Control", "no-cache");
  459.     xmlRequest.send("username=" + username.value + "&hashed_password=" + hashed);
  460. }
  461.  
  462. function verifyOnLoad(event)
  463. {
  464.     document.getElementById("loginstatus").innerHTML = 'Please wait, verifying...';
  465.     var username = document.getElementById("username");
  466.     var hashed = widget.preferenceForKey('password');
  467.     // Values you provide
  468.     var URL = "http://localhostr.com/api_verify";                        // The feed to fetch
  469.     var onloadHandler = function() { xmlLoaded(xmlRequest, username, 'hashed'); };    // The function to call when the feed is loaded; currently calls the XMLHttpRequest load snippet
  470.     // XMLHttpRequest setup code
  471.     var xmlRequest = new XMLHttpRequest();
  472.     xmlRequest.onload = onloadHandler;
  473.     xmlRequest.open("POST", URL);
  474.     xmlRequest.setRequestHeader("Cache-Control", "no-cache");
  475.     xmlRequest.send("username=" + username.value + "&hashed_password=" + hashed);
  476. }
  477.  
  478. // Called when an XMLHttpRequest loads a feed; works with the XMLHttpRequest setup snippet
  479. function xmlLoaded(xmlRequest, username, password) 
  480. {
  481.     if (xmlRequest.status == 200) {
  482.         // Parse and interpret results
  483.         // XML results found in xmlRequest.responseXML
  484.         // Text results found in xmlRequest.responseText
  485.         if(xmlRequest.responseText == 'found')
  486.         {
  487.             widget.setPreferenceForKey(username.value, 'username');
  488.             if (password != 'hashed')
  489.                 var hashed = widget.system('/bin/echo -n "' + password.value + '" | /usr/bin/openssl dgst -sha1 ', null).outputString;
  490.             
  491.             widget.setPreferenceForKey(hashed, 'password');
  492.             document.getElementById("loginstatus").innerHTML = "<span style='color:#6dff6c'>User Verfied</span>";
  493.         }
  494.         else document.getElementById("loginstatus").innerHTML = xmlRequest.responseText;
  495.     }
  496.     else {
  497.         alert("Error fetching data: HTTP status " + xmlRequest.status);
  498.     }
  499. }
  500.  
  501. function mouseDown(event)
  502. {
  503.  
  504.     document.addEventListener("mousemove", mouseMove, true);
  505.     document.addEventListener("mouseup", mouseUp, true);
  506.  
  507.     growboxInset = {x:(window.innerWidth - event.x), y:(window.innerHeight - event.y)};
  508.  
  509.     event.stopPropagation();
  510.     event.preventDefault();
  511. }
  512.  
  513. function mouseMove(event)
  514. {
  515.     var y = event.y + growboxInset.y;
  516.     adjustWidgetHeight(y, 0, 1)
  517.     
  518.     event.stopPropagation();
  519.     event.preventDefault();
  520. }
  521.  
  522. function adjustWidgetHeight(y, animate, permenant)
  523. {
  524.     if (animate <= 0)
  525.     {
  526.         if (y < 265 && y > 228) {
  527.             y = 265;
  528.             document.getElementById('scrollBar').style.display = 'block';
  529.         }
  530.         else if (y < 228) {
  531.             y = 192;
  532.             document.getElementById('scrollBar').style.display = 'none';
  533.         }
  534.         else {
  535.             document.getElementById('scrollBar').style.display = 'block';
  536.         }
  537.         document.getElementById("resize").style.top = (y-53);
  538.         window.resizeTo(317,y);
  539.         scrollAreaDiv.style.height = y-192 + 'px';
  540.         document.getElementById('scrollBar').style.height = y-192 + 'px';
  541.         scrollArea.refresh();
  542.         if (permenant > 0)
  543.             widget.setPreferenceForKey(y.toString(), 'lhwidgetheight');
  544.     }
  545.     
  546.     else
  547.     {
  548.         if (y < 265 && y >= 228) {
  549.             y = 265;
  550.             document.getElementById('scrollBar').style.display = 'block';
  551.         }
  552.         else if (y < 228) {
  553.             y = 192;
  554.             document.getElementById('scrollBar').style.display = 'none';
  555.         }
  556.         else {
  557.             document.getElementById('scrollBar').style.display = 'block';
  558.         }
  559.         
  560.         currentAnimator = new AppleAnimator(500, 13);
  561.         currentAnimation = new AppleAnimation(animate, y, resizeAnimator);
  562.         currentAnimator.addAnimation(currentAnimation);
  563.         currentAnimator.start();
  564.         
  565.         function resizeAnimator(animation, current, start, finish)
  566.         {
  567.             window.resizeTo(317,current);
  568.             document.getElementById("resize").style.top = (current-53);
  569.             scrollAreaDiv.style.height = current-192 + 'px';
  570.             document.getElementById('scrollBar').style.height = current-192 + 'px';
  571.             scrollArea.refresh();
  572.         }
  573.         
  574.         if (permenant > 0)
  575.             widget.setPreferenceForKey(y.toString(), 'lhwidgetheight');
  576.     }
  577. }
  578.  
  579.  
  580. function mouseUp(event)
  581. {
  582.     document.removeEventListener("mousemove", mouseMove, true);
  583.     document.removeEventListener("mouseup", mouseUp, true);
  584.     
  585.     event.stopPropagation();
  586.     event.preventDefault();
  587. }
  588.  
  589. function checkForUpdates(event)
  590. {
  591.     alert('Checking for updates...');
  592.     // Values you provide
  593.     var URL = "http://simon360.com/localhostr/latestversion.php";    // The feed to fetch
  594.     var onloadHandler = function() { updateResponse(xmlRequest); };    // The function to call when the feed is loaded; currently calls the XMLHttpRequest load snippet
  595.     // XMLHttpRequest setup code
  596.     var xmlRequest = new XMLHttpRequest();
  597.     xmlRequest.onload = onloadHandler;
  598.     xmlRequest.open("POST", URL);
  599.     xmlRequest.setRequestHeader("Cache-Control", "no-cache");
  600.     xmlRequest.send(null);
  601. }
  602.  
  603. function updateResponse(xmlRequest) 
  604. {
  605.     if (xmlRequest.status == 200) {
  606.         // Parse and interpret results
  607.         // XML results found in xmlRequest.responseXML
  608.         // Text results found in xmlRequest.responseText
  609.         responseStuff = xmlRequest.responseText.split(',');
  610.         if (responseStuff[0] > 1.10)
  611.         {
  612.             document.getElementById('updateAvailable').style.display="block";
  613.             document.getElementById('updateAvailable').onclick = function(){widget.openURL(responseStuff[1])};
  614.             document.getElementById('updateAvailable').style.cursor='pointer';
  615.             alert('Update available!');
  616.         }
  617.         else
  618.         {
  619.             updateTimer = setTimeout("checkForUpdates()", 3600000);
  620.             alert('No updates available.');
  621.         }
  622.     }
  623.     else {
  624.         alert("Error fetching data: HTTP status " + xmlRequest.status);
  625.     }
  626. }
  627.  
  628. function toggleUpdates(event)
  629. {
  630.     if (document.getElementById('updatesOnOff').checked == true) {
  631.         widget.setPreferenceForKey('1', 'updatesOnOff')
  632.         alert('Updates on');
  633.         checkForUpdates(null);
  634.     }
  635.     else {
  636.         widget.setPreferenceForKey('0', 'updatesOnOff');
  637.         clearTimeout(updateTimer);
  638.         alert('Updates off');
  639.     }
  640. }
  641.  
  642. function toggleCopy(event)
  643. {
  644.     if (document.getElementById('copyOnOff').checked == true) {
  645.         widget.setPreferenceForKey('1', 'autocopy')
  646.         alert('Autocopy on');
  647.     }
  648.     else {
  649.         widget.setPreferenceForKey('0', 'autocopy');
  650.         clearTimeout(updateTimer);
  651.         alert('Autocopy off');
  652.     }
  653. }
  654.